<?php
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery-ui-1.8.11.custom.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.tipsy.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.wysiwyg.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/jquery.artDialog.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/plugins/iframeTools.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine-zh_CN.js",CClientScript::POS_HEAD);


?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/art-dialog/skins/blue.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/validationEngine.jquery.css" />
<style type="text/css">
    .st-labeltext {
        color: #3C5868;
        display: block;
        float: left;
        font-size: 12px;
        line-height: 20px;
        padding-right: 10px;
        padding-top: 3px;
        width: 60px;
    }
</style>
<div style="z-index: 770;" class="albox succesbox">
    <span id="is_type" style="color: red;">基本信息</span>
</div>
<form id="form"  method="post" >
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">度假村名称:</span>
    <span style="font-size: 14px;"><?php echo $info->title; ?></span>
    <div class="clear" style="z-index: 570;"></div>
</div>
<div style="z-index: 680;" class="st-form-line">
    <span class="st-labeltext">区域:</span>
    <?php foreach($city as $k=>$v){ ?>
        <?php if($v->id==$info->area){ ?>
        <span style="font-size: 14px;"><?php echo $v->name; ?></span>
        <?php } ?>
    <?php } ?>
    <div style="z-index: 670;" class="clear"></div>
</div>
<div style="z-index: 680;" class="st-form-line">
    <span class="st-labeltext">适合人群:</span>
    <?php $people_arr = explode(",",$info->people); ?>
    <?php foreach($people as $k=>$v){ ?>
    <label><input type="checkbox" <?php if(in_array($k,$people_arr)){ ?>checked="checked"<?php } ?>  name="people[]" class="validate[minCheckbox[1]]" value="<?php echo $k; ?>"><?php echo $v; ?></label>
    <?php } ?>
    <div style="z-index: 670;" class="clear"></div>
</div>
<div style="z-index: 680;" class="st-form-line">
    <span class="st-labeltext">游玩主题:</span>
    <?php $theme_arr = explode(",",$info->theme); ?>
    <?php foreach($theme as $k=>$v){ ?>
    <label><input type="checkbox" <?php if(in_array($k,$theme_arr)){ ?>checked="checked"<?php } ?> name="theme[]" class="validate[minCheckbox[1],maxCheckbox[5]]"  value="<?php echo $k; ?>"><?php echo $v; ?></label>
    <?php } ?>
    <div style="z-index: 670;" class="clear"></div>
</div>
<div style="z-index: 680;" class="st-form-line">
    <span class="st-labeltext">特色:</span>
    <textarea id="description" name="Article[description]" class="validate[required,minSize[6],maxSize[250]]" style="width:500px;background-color: #eaf2ec;" cols="47" rows="3"><?php echo $info->description; ?></textarea>
    <div style="z-index: 670;" class="clear"></div>
</div>
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">价格:</span>
    <input type="text" value="<?php echo $info->price; ?>" name="Article[price]" style="width:200px;margin-bottom: 10px;float: left" id="price" class="st-success-input  validate[required,custom[number],maxSize[10]]" data-errormessage-range-overflow="价格不得大于10位" data-errormessage-value-missing="价格不得为空" data-errormessage-custom-error="请填写数字" ><span style="color: red;font-size: 14px;margin-left:10px;">免费请填写0</span>
    <div class="clear" style="z-index: 570;"></div>
</div>
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">电话:</span>
    <input type="text" value="<?php echo $info->phone; ?>"  name="Article[phone]" style="width:200px;margin-bottom: 10px;float: left" id="phone" class="st-success-input validate[required,maxSize[20]]" data-errormessage-range-overflow="电话不得大于20位" data-errormessage-value-missing="电话不得为空" >
    <div class="clear" style="z-index: 570;"></div>
</div>
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">地址:</span>
    <input type="text" value="<?php echo $info->address; ?>" name="Article[address]" style="width:500px;margin-bottom: 10px;float: left" id="address" class="st-success-input validate[required,maxSize[200]]" data-errormessage-range-overflow="地址不得大于200位" data-errormessage-value-missing="地址不得为空" >
    <div class="clear" style="z-index: 570;"></div>
</div>
<div style="z-index: 460;margin-left:200px;" class="st-form-line button-box">
    <input type="button" name="map" id="map" value="地图标注" style="width: 300px;" class="st-button">
    <input type="hidden" name="ArticleData[coordinate]" value="<?php echo $info_data->coordinate; ?>" id="coordinate">
</div>
<div class="st-form-line" style="z-index: 650;">
    <span class="st-labeltext">缩略图</span>
    <a original-title="选择图片" href="javascript:uploadifyAction('thumbWarp','thumb'); " style="float: left"  class="icon-button tips">
        <img width="18" height="18" src="<?php echo $this->adminPath; ?>/img/icons/sidemenu/image.png" alt="icon">
    </a>
    <ul id="thumbWarp">
        <li id="image_update_<?php echo $info->id ?>"><img width="40" height="40" align="absmiddle" src="<?php echo Yii::app()->homeUrl.$info->thumb; ?>"><a href="javascript:uploadifyUpdateRemove(<?php echo $info->id ?>,'image_update_')">删除</a><input type="hidden" value="<?php echo $info->thumb ?>" id="thumb" name="thumb"><br></li>
    </ul>
    <div class="clear" style="z-index: 640;"></div>
</div>
<div style="z-index: 770;" class="albox succesbox">
    <span id="is_type" style="color: red;">详细信息</span>
</div>
<div class="st-form-line">
    <div class="simplebox grid550-left">
        <div class="titleh">
            <h3>交通信息：</h3>
        </div>
        <div class="body">
            <textarea style="width: 96.5%;height: 150px;background-color: #eaf2ec;"  name="ArticleData[traffic_info]" id="traffic_info"><?php echo CHtml::decode($info_data->traffic_info); ?></textarea>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="st-form-line">
    <div class="simplebox grid550-left">
        <div class="titleh">
            <h3>酒店说明：</h3>
        </div>
        <div class="body">
            <textarea style="width: 96.5%;height: 150px;background-color: #eaf2ec;"  name="ArticleData[content]" id="content"><?php echo CHtml::decode($info_data->content); ?></textarea>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="st-form-line">
    <div class="simplebox grid550-left">
        <div class="titleh">
            <h3>住宿环境说明：</h3>
        </div>
        <div class="body">
            <textarea style="width: 96.5%;height: 150px;background-color: #eaf2ec;"  name="ArticleData[zhusu_info]" id="zhusu_info"><?php echo CHtml::decode($info_data->zhusu_info); ?></textarea>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="st-form-line">
    <div class="simplebox grid550-left">
        <div class="titleh">
            <h3>好吃的说明：</h3>
        </div>
        <div class="body">
            <textarea style="width: 96.5%;height: 150px;background-color: #eaf2ec;"  name="ArticleData[food_info]" id="food_info"><?php echo CHtml::decode($info_data->food_info); ?></textarea>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="st-form-line">
    <div class="simplebox grid550-left">
        <div class="titleh">
            <h3>好玩的说明：</h3>
        </div>
        <div class="body">
            <textarea style="width: 96.5%;height: 150px;background-color: #eaf2ec;"  name="ArticleData[happy_info]" id="happy_info"><?php echo CHtml::decode($info_data->happy_info); ?></textarea>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div style="z-index: 770;" class="albox succesbox">
    <span id="is_type" style="color: red;">相关信息</span>
</div>
<div class="st-form-line" style="z-index: 630;">
    <span class="st-labeltext">度假村图集</span>
    <a original-title="上传图集" href="javascript:uploadifyAllAction('thumbImagesWarp','image_path');" style="float: left" class="icon-button tips">
        <img width="18" height="18" src="<?php echo $this->adminPath; ?>/img/icons/16x16/note.png" alt="icon">
    </a>
    <div class="clear" style="z-index: 620;"></div>
    <ul id="thumbImagesWarp">
        <?php if($image_info){ ?>
            <?php foreach($image_info as $k=>$v){ ?>
            <li  style="margin-bottom: 5px;" id="images_update_<?php echo $v->id; ?>">
                <img width="40" height="40" src="<?php echo Yii::app()->homeUrl.$v->image_path; ?>">&nbsp;
                <a href="javascript:uploadifyUpdateRemove(<?php echo $v->id; ?>,'images_update_')">删除</a>
                <input type="hidden" value="<?php echo $v->image_path ?>" name="image_path[]">
                <br>
            </li>
            <?php } ?>
        <?php } ?>
    </ul>
    <div class="clear" style="z-index: 620;"></div>
</div>
    <div class="st-form-line" style="z-index: 630;">
        <span class="st-labeltext">住宿环境图集</span>
        <a original-title="上传图集" href="javascript:uploadifyAllAction('thumbImagesZhusuWarp','image_zhusu_path');" style="float: left" class="icon-button tips">
            <img width="18" height="18" src="<?php echo $this->adminPath; ?>/img/icons/16x16/note.png" alt="icon">
        </a>
        <div class="clear" style="z-index: 620;"></div>
        <ul id="thumbImagesZhusuWarp">
            <?php if($image_zhusu_info){ ?>
                <?php foreach($image_zhusu_info as $k=>$v){ ?>
                    <li  style="margin-bottom: 5px;" id="images_shusu_update_<?php echo $v->id; ?>">
                        <img width="40" height="40" src="<?php echo Yii::app()->homeUrl.$v->image_path; ?>">&nbsp;
                        <a href="javascript:uploadifyUpdateRemove(<?php echo $v->id; ?>,'images_zhusu_update_')">删除</a>
                        <input type="hidden" value="<?php echo $v->image_path ?>" name="image_zhusu_path[]">
                        <br>
                    </li>
                <?php } ?>
            <?php } ?>
        </ul>
        <div class="clear" style="z-index: 620;"></div>
    </div>
    <div class="st-form-line" style="z-index: 630;">
        <span class="st-labeltext">好吃的图集</span>
        <a original-title="上传图集" href="javascript:uploadifyAllAction('thumbImagesFoodWarp','image_food_path');" style="float: left" class="icon-button tips">
            <img width="18" height="18" src="<?php echo $this->adminPath; ?>/img/icons/16x16/note.png" alt="icon">
        </a>

        <div class="clear" style="z-index: 620;"></div>
        <ul id="thumbImagesFoodWarp">
            <?php if($image_food_info){ ?>
                <?php foreach($image_food_info as $k=>$v){ ?>
                    <li  style="margin-bottom: 5px;" id="images_food_update_<?php echo $v->id; ?>">
                        <img width="40" height="40" src="<?php echo Yii::app()->homeUrl.$v->image_path; ?>">&nbsp;
                        <a href="javascript:uploadifyUpdateRemove(<?php echo $v->id; ?>,'images_food_update_')">删除</a>
                        <input type="hidden" value="<?php echo $v->image_path ?>" name="image_food_path[]">
                        <br>
                    </li>
                <?php } ?>
            <?php } ?>
        </ul>
        <div class="clear" style="z-index: 620;"></div>
    </div>

<div class="st-form-line" style="z-index: 630;">
    <span class="st-labeltext">好玩的图集</span>
    <a original-title="上传图集" href="javascript:uploadifyAllAction('thumbImagesHappyWarp','image_happy_path');" style="float: left" class="icon-button tips">
        <img width="18" height="18" src="<?php echo $this->adminPath; ?>/img/icons/16x16/note.png" alt="icon">
    </a>
    <div class="clear" style="z-index: 620;"></div>
    <ul id="thumbImagesHappyWarp">
        <?php if($image_happy_info){ ?>
            <?php foreach($image_happy_info as $k=>$v){ ?>
                <li  style="margin-bottom: 5px;" id="images_happy_update_<?php echo $v->id; ?>">
                    <img width="40" height="40" src="<?php echo Yii::app()->homeUrl.$v->image_path; ?>">&nbsp;
                    <a href="javascript:uploadifyUpdateRemove(<?php echo $v->id; ?>,'images_happy_update_')">删除</a>
                    <input type="hidden" value="<?php echo $v->image_path ?>" name="image_happy_path[]">
                    <br>
                </li>
            <?php } ?>
        <?php } ?>
    </ul>
    <div class="clear" style="z-index: 620;"></div>
</div>








































<div class="st-form-line button-box"  style="z-index: 460;margin-left:200px;">
    <ul id="relatedWarp" style="font-size: 14px;">
        <?php if($ambitus_info){ ?>
            <?php foreach($ambitus_info as $k=>$v){ ?>
            <li style="padding:5px 5px;cursor: pointer;border-bottom: 1px solid #ccc;display: table;" id="related_update_<?php echo $v->article_id; ?>"><label><?php echo $v->au->title; ?></label><span style="margin-left: 170px;"><a href="javascript:relatedRemove(<?php echo $v->article_id; ?>,'related_update_')">删除</a></span><input type="hidden" value="<?php echo $v->article_id; ?>" name="relation[]"></li>
            <?php } ?>
        <?php } ?>
    </ul>
    <div class="clear" style="z-index: 620;"></div>
</div>

<div class="st-form-line button-box" style="z-index: 460;margin-left:200px;">

    <input type="button" class="st-button" style="width: 300px;" value="添加周边景点" id="related" name="related">


    <div class="clear" style="z-index: 620;"></div>
</div>

    <div class="st-form-line button-box" style="z-index: 460;">
    <input type="submit" class="st-button" value="保存" id="submit" name="button">
</div>
</form>

<script type="text/javascript">
    $('#traffic_info,#content,#zhusu_info,#food_info,#happy_info').wysiwyg({
        controls: {
            bold : {visible : true},
            italic        : { visible : true },
            strikeThrough : { visible : true },
            underline     : { visible : true },
            separator00 : { visible : true },
            justifyLeft   : { visible : true },
            justifyCenter : { visible : true },
            justifyRight  : { visible : true },
            justifyFull   : { visible : true },
            separator01 : { visible : true },
            indent  : { visible : true },
            outdent : { visible : true },
            separator02 : { visible : true },
            subscript   : { visible : true },
            superscript : { visible : true },
            separator03 : { visible : true },
            undo : { visible : true },
            redo : { visible : true },
            separator04 : { visible : true },
            insertOrderedList    : { visible : true },
            insertUnorderedList  : { visible : true },
            insertHorizontalRule : { visible : true },
            separator05 : { separator : true },
            createLink:{
                visible : false,
                tooltip : '选择文字添加超链接'
            }

        }
    });




    $(function() {
        $("#related").click(function(){
            art.dialog.open(
                '<?php echo Yii::app()->createAbsoluteUrl("admin/public/getRelated",array('type'=>'resort','city'=>$info->city_id)); ?>',
                {
                    title:'周边',
                    lock: true,
                    width: 700,
                    height: 580,
                    close: function(){
                        var aid = art.dialog.data('aid');
                        var atitle = art.dialog.data('atitle');
                        if(aid && atitle){
                            var str = '';
                            str += '<li id="related_'+aid+'" style="padding:5px 5px;cursor: pointer;border-bottom: 1px solid #ccc;display: table;"><label>'+atitle+'</label><span style="margin-left: 170px;"><a href="javascript:relatedRemove('+aid+',\'related_\')">删除</a></span><input name="relation[]" value="'+aid+'" type="hidden" /></li>';
                            $("#relatedWarp").append(str);
                        }
                    }
                });
        });
    });
    function relatedRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $("#"+attrName+fileId).remove();
        }
    }
    //图集上传
    function uploadifyAllAction(Warp,Name){
        art.dialog.data('Warp',Warp);
        art.dialog.data('Name',Name);
        art.dialog.open(
            '<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/basicAll",array('num'=>8)); ?>',
            {
                title:'附件上传',
                lock: false,
                width: 600,
                height: 300,
                ok: function () {
                    var fileListWarp = art.dialog.data('fileListWarp');
                    $("#"+Warp).append(fileListWarp);
                    this.close();
                    return false;
                },
                cancelVal: '取消',
                cancel: true
            }

        );
    }

    //缩略图上传
    function uploadifyAction(Warp,Name) {
        art.dialog.data('Warp',Warp);
        art.dialog.data('Name',Name);
        art.dialog.open(
            '<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/basic"); ?>',
            {
                title:'附件上传',
                lock: false,
                width: 600,
                height: 300,
                ok: function () {
                    var fileListWarp = art.dialog.data('fileListWarp');
                    $("#"+Warp).html(fileListWarp);
                    this.close();
                    return false;
                },
                cancelVal: '取消',
                cancel: true
            }

        );
    }
    function uploadifyRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $.post(
                "<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/remove"); ?>",
                {imageId:fileId},
                function(res){
                    $("#"+attrName+fileId).remove();
                },
                'json'
            );
        }
    }
    function uploadifyUpdateRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $("#"+attrName+fileId).remove();
        }
    }






    $(function(){
        $("#map").click(function(){
            var city_name = '<?php echo $city_info->cn_name; ?>';
            art.dialog.open(
                '<?php echo Yii::app()->createAbsoluteUrl("admin/commonsUpdate/getMap"); ?>',
                {
                    title:'地图标注',
                    lock: true,
                    width: 700,
                    height: 500,
                    close: function(){
                        var maps = art.dialog.data('maps');
                        $("#coordinate").val(maps);
                    }
                });
            art.dialog.data('city_address', city_name);
            art.dialog.data('coordinate', $("#coordinate").val());
        });
    });



    $(function(){
        $("#form").validationEngine({
            ajaxFormValidation: true,
            ajaxFormValidationURL: '<?php echo Yii::app()->createAbsoluteUrl('admin/commonsUpdate/resortUpdate',array('token'=>$info->token)); ?>',
            ajaxFormValidationMethod: "post",
            //validateNonVisibleFields:true,//验证隐藏字段
            onBeforeAjaxFormValidation: function (form, options) {
                art.dialog.Talert('数据交互中ing', 5);
            },
            onAjaxFormComplete: function (status, form, json, options) {
                if (json['status'] == 1) {
                    art.dialog.Talert(json['message']);
                    window.location.href="<?php echo Yii::app()->createAbsoluteUrl('resort/show',array('show'=>'yes','token'=>$info->token)); ?>";
                } else {
                    art.dialog.Talert(json['message']);
                }
            }

        });
    });
</script>
